import requestChat, { IMessage } from '../utils/request-chat'
import request from '../utils/request-new'

// 对话
export const completions = (data: {
  messages: IMessage[],
  modelId: string,
  success: Function
}) => {
  return requestChat({
    url: '/v1/chat/completions/ask',
    method: 'POST',
    data: {
      ...data,
      stream: true
    },
    success: data.success
  })
}

// 对话
export const caseIdentify = (data: {
  type: string,
  text?: string,
  fileName?: string,
  imgUrl?: string
}) => {
  const params = {
    type: data.type,
    stream: false
  }
  if(data.text){
    params.text = data.text
  }
  if(data.fileName){
    params.fileName = data.fileName
  }
  if(data.imgUrl){
    params.imgUrl = data.imgUrl
  }
  return request({
    url: `/v1/chat/completions/${data.type}`,
    method: 'POST',
    data: params
  })
}